<template>
    
    <!-- 组件的模板 -->
    <div class="page add-member">        
        <div class="weui-cells weui-cells_radio select-role">
            <label class="weui-cell weui-check__label" :for="'x'+item.id" v-for="item in roleListAarr" @click="getCurrRole(item.id,item.name)">
                <div class="weui-cell__bd">
                    <h2>{{item.name}}</h2>
                    <p v-if="item.id==2">具备企业的所有管理功能</p>
                    <p v-if="item.id==5">可以查看和管理自己项目，并使用企业人才库</p>                    
                    <p v-if="item.id==8">可以查看和管理本部门的项目</p>

                </div>
                <div class="weui-cell__ft">
                    <input type="radio" class="weui-check" name="radio1" :id="'x'+item.id">
                    <span class="weui-icon-checked"></span>
                </div>
            </label>
        </div>
    </div>   
</template>

<script>  
    /**
     *  引入工具类库 或 Native API
     *  example : import widget from 'gapi/widget'
     */
    import clientUi from 'gapi/clientUi.js'
    import widget from 'gapi/widget.js'
    import teamApi from 'clientApi/teamApi.js'
    import * as util from 'js/util.js'
    import cache from 'gapi/cache.js'
    import commonPage from 'clientApi/commonPage.js'
    /**
     *  引入组件 以及 组件接口(Action)
     *  example : import Somecomponents from 'components/Somecomponents/Somecomponents'
     */

    /**
     *  组件实例对象
     */
    export default {
        components: {

        },
        data: function(){
            return{
               teamid:'',
               roleListAarr:[]
            }
        },
        vuex: {
            getters: {

            },
            actions: {

            }
        },
        methods: {
            /**
             * 初始化
             * @method init
             * @public
             * @return {Null} void
             */
            init (){
                this.teamid = util.getUrddataString('teamId') 
                commonPage.loadPageStatus('loading')
                 util.ajax({
                    url:'/team/member/editable/roles',
                    type:'GET',
                    data:{
                        team_id:this.teamid,
                        project_id:0
                    },
                    timeout:10000,
                    success:(obj) => {
                        // alert(JSON.stringify(obj))
                        commonPage.loadPageStatus('loadSuccess')
                        if(obj){
                            if(obj.errno == 0){
                                this.roleListAarr = obj.data
                            }
                        }
                    },
                    error: (xhr, status) => {
                        commonPage.loadPageStatus('loadSuccess')
                        widget.toast('服务器异常')
                    },
                    noNetwork: () => {
                        // 无网络的回调 
                        commonPage.loadPageStatus('loadSuccess')
                        widget.toast('网络连接失败，请检查网络')
                    }
                })
            },
            getCurrRole (id,name){
                let selectRole = {
                    id:id,
                    name:name
                }
                cache.getMemoryCache('memberInfoWebViewID',(data)=>{
                    if(data){ 
                        commonPage.goBack(1,{'key':'teamSelectRole','value': selectRole},data.webViewID)
                    }
                })
            }
        },
        created(){

            this.init();
            commonPage.updateTitleBar({
                backAction: 'gotoback',
                leftAction: 'gotoback'
            })

           window.gotoback = () => {
            commonPage.goBack(1)
           }
            
        }
        
    }

    
</script>

<!-- CSS 样式 -->
<style src="../../node_modules/weui/dist/style/weui.css"></style>
<style src="../../static/css/common.css"></style>
<style src="../../static/css/project.css"></style>



